package com.example.httpstest;

import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class CustomSSLSocketFactory {
	SSLContext sslcontext;

	private CustomSSLSocketFactory() throws NoSuchAlgorithmException,
			KeyManagementException {
		super();

		// this.sslcontext = null;
		// this.socketfactory = HttpsURLConnection.getDefaultSSLSocketFactory();
		// this.nameResolver = null;

		this.sslcontext = SSLContext.getInstance("TLS");
		this.sslcontext.init(null, new TrustManager[] { new X509TrustManager() {
			public java.security.cert.X509Certificate[] getAcceptedIssuers() {
				return null;
			}

			public void checkClientTrusted(
					java.security.cert.X509Certificate[] certs, String authType) {
			}

			public void checkServerTrusted(
					java.security.cert.X509Certificate[] certs, String authType) {
			}
		} }, new SecureRandom());
		// this.socketfactory = this.sslcontext.getSocketFactory();
		// this.nameResolver = null;
	}

}
